{extend name="layout:base" /}

{block name="body"}

{include file="common:nav" /}

<div class="container">
    <div class="row bg-fff mt-20 pt-15-pb-15">
        <div class="col-lg-12">
            <a href="{:url('index/rule/index')}" class="btn btn-primary">返回规则列表</a>
        </div>

        <div class="col-lg-12 pt-15-pb-15">
            <div class="panel panel-default">
                <div class="panel-body">
                    <form action="{:url('index/rule/update', ['id' => $rule['id']])}" method="post" class="form-horizontal">
                        {:token()}
                        <div class="form-group">
                            <label class="control-label col-sm-2">规则名</label>
                            <div class="col-sm-10">
                                <input type="text" name="rule_name" value="{$rule.rule_name}" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">排序</label>
                            <div class="col-sm-10">
                                <input type="number" name="rule_sort" value="{$rule.rule_sort}" class="form-control">
                            </div>
                            <div class="col-sm-10 col-sm-offset-2">
                                <span class="help-block">注意：越小越靠前</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">匹配类型</label>
                            <div class="col-sm-10">
                                <input type="radio" name="rule_type" value="equal" {$rule['rule_type'] == 'equal' ? 'checked' : ''}> 完全相等
                                <input type="radio" name="rule_type" value="include" {$rule['rule_type'] == 'include' ? 'checked' : ''}> 包含关键字
                                <input type="radio" name="rule_type" value="reg" {$rule['rule_type'] == 'reg' ? 'checked' : ''}> 正则表达式
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">匹配内容</label>
                            <div class="col-sm-10">
                                <input type="text" name="rule_content" value="{$rule.rule_content}" class="form-control">
                            </div>
                            <div class="col-sm-10 col-sm-offset-2">
                                <span class="help-block">直接输入需要匹配的内容，正则表达式就输入正则表达式即可。</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">规则状态</label>
                            <div class="col-sm-10">
                                <input type="radio" name="rule_status" value="1" {$rule['rule_status'] == 1 ? 'checked' : ''}> 正常
                                <input type="radio" name="rule_status" value="-1" {$rule['rule_status'] == -1 ? 'checked' : ''}> 停止
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-10 col-sm-offset-2">
                                <button type="submit" class="btn btn-primary">编辑</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>

    </div>
</div>

{include file="common:footer" /}

{/block}

{block name="footer"}
<script>
    require(["icheck"], function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_minimal-green',
            radioClass: 'iradio_minimal-green',
            increaseArea: '20%'
        });
    });
</script>
{/block}